<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div class="course-position">
    <div class="course-bar">课表信息</div>

    <table class="course-table">
        <tr>
            <td colspan="8">我的课表</td>
        </tr>

        <tr>
            <th>节次/周次</th>
            <th>星期一</th>
            <th>星期二</th>
            <th>星期三</th>
            <th>星期四</th>
            <th>星期五</th>
            <th>星期六</th>
            <th>星期日</th>
        </tr>

        <tr>
            <td id="T1_0">第一节</td>
            <td id="T1_1"></td>
            <td id="T1_2"></td>
            <td id="T1_3"></td>
            <td id="T1_4"></td>
            <td id="T1_5"></td>
            <td id="T1_6"></td>
            <td id="T1_7"></td>
        </tr>

        <tr>
            <td id="T2_0">第二节</td>
            <td id="T2_1"></td>
            <td id="T2_2"></td>
            <td id="T2_3"></td>
            <td id="T2_4"></td>
            <td id="T2_5"></td>
            <td id="T2_6"></td>
            <td id="T2_7"></td>
        </tr>

        <tr>
            <td id="T3_0">第三节</td>
            <td id="T3_1"></td>
            <td id="T3_2"></td>
            <td id="T3_3"></td>
            <td id="T3_4"></td>
            <td id="T3_5"></td>
            <td id="T3_6"></td>
            <td id="T3_7"></td>
        </tr>

        <tr>
            <td id="T4_0">第四节</td>
            <td id="T4_1"></td>
            <td id="T4_2"></td>
            <td id="T4_3"></td>
            <td id="T4_4"></td>
            <td id="T4_5"></td>
            <td id="T4_6"></td>
            <td id="T4_7"></td>
        </tr>

        <tr>
            <td id="T5_0">第五节</td>
            <td id="T5_1"></td>
            <td id="T5_2"></td>
            <td id="T5_3"></td>
            <td id="T5_4"></td>
            <td id="T5_5"></td>
            <td id="T5_6"></td>
            <td id="T5_7"></td>
        </tr>

        <tr>
            <td id="T6_0">第六节</td>
            <td id="T6_1"></td>
            <td id="T6_2"></td>
            <td id="T6_3"></td>
            <td id="T6_4"></td>
            <td id="T6_5"></td>
            <td id="T6_6"></td>
            <td id="T6_7"></td>
        </tr>

    </table>

</div>


<script type="text/javascript">

    function ajax(url, send, postback, f, moth) {
        if (!url) return;
        moth = "GET";
        var ajx = new XMLHttpRequest();
        ajx.open(moth, url, !f);
        ajx.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        if (postback) ajx.onreadystatechange = function () {
            if (ajx.readyState == 4 && ajx.status == 200) postback(ajx.responseText)
        };
        ajx.send(send)
    }


    function creatCourseTab() {
        const stusno = 7650;
        ajax("getCourseTable", "ssid=" + stusno, postback);

        function postback(x) {
            if (x == "no")
                return;
            else {
                var list = eval("(" + x + ")");
                for (var i = 0; i < list.length; i++) {
                    //解析json数据
                    var jieci = list[i].session;
                    var week = list[i].week;
                    var cno = list[i].id;
                    var cname = list[i].courseName;
                    var croom = list[i].courseRoom;
                    var tname = list[i].teacherName;

                    switch (jieci) {
                        case "第一节":
                            jieci = 1;
                            break;
                        case "第二节":
                            jieci = 2;
                            break;
                        case "第三节":
                            jieci = 3;
                            break;
                        case "第四节":
                            jieci = 4;
                            break;
                        case "第五节":
                            jieci = 5;
                            break;
                        case "第六节":
                            jieci = 6;
                            break;
                    }
                    switch (week) {
                        case "星期一":
                            week = 1;
                            break;
                        case "星期二":
                            week = 2;
                            break;
                        case "星期三":
                            week = 3;
                            break;
                        case "星期四":
                            week = 4;
                            break;
                        case "星期五":
                            week = 5;
                            break;
                        case "星期六":
                            week = 6;
                            break;
                        case "星期日":
                            week = 7;
                            break;
                    }
                    //确定单元格
                    var danyuange = document.getElementById("T" + jieci + "_" + week);

                    //写入数据
                    var content = cname + "(" + cno + ")" + "(" + tname + ")" + "<br>" + "(" + croom + ")";
                    danyuange.innerHTML = content;
                    danyuange.style.backgroundColor = "rgb(148, 174, 243)";

                }
            }

        }
    }

    creatCourseTab();

</script>

</body>
</html>